<?php
/** class for loading methods without module, ex. login, logout, etc.
 *		(site.com/login)
**/

class Common extends Controller
{
	function __construct(){}
	
	function login()
	{
		if (isset($_POST['login']) && isset($_POST['passwd']))
		{
			$mod = load_model('user_model');
			if ($id = $mod->login($_POST['login'], $_POST['passwd']))
			{
				$_SESSION['user_id'] = $id;
				header('Location: /admin/blog/');
				exit();
			}
		}
		parent::$tpl->display('login.tpl');
		exit();
	}
	
	function logout()
	{
		$_SESSION['user_id'] = 0;
		header('Location: /admin/login.html');
		exit();
	}
	
	
	
	
	
	function blogxml()
	{
		$model = load_model('blog_model');
		$items = array();
		$items = $model->getItems();
		
		header('Content-type: text/xml');
		parent::$tpl->assign('items', $items);
		echo parent::$tpl->fetch('blog.xml.tpl');
		
		exit();
	}
	
	function blogrss()
	{
		$model = load_model('blog_model');
		$items = array();
		$items = $model->getItems(1, 10);
		
		header('Content-type: text/xml');
		parent::$tpl->assign('items', $items);
		echo parent::$tpl->fetch('blog.rss.tpl');
		
		exit();
	}
	
	function portfolioxml()
	{
		$model = load_model('portfolio_model');
		$items = array();
		$items = $model->getItems();
		
		header('Content-type: text/xml');
		parent::$tpl->assign('items', $items);
		echo parent::$tpl->fetch('portfolio.xml.tpl');
		
		exit();
	}
	
	function portfoliorss()
	{
		$model = load_model('portfolio_model');
		$items = array();
		$items = $model->getItems(1, 10);
		
		header('Content-type: text/xml');
		parent::$tpl->assign('items', $items);
		echo parent::$tpl->fetch('portfolio.rss.tpl');
		
		exit();
	}
	
	
	
	
	function rss()
	{
		$model = load_model('rss_model');
		$items = array();
		$items = $model->getFeed(20);
		
		header('Content-type: text/xml');
		parent::$tpl->assign('items', $items);
		echo parent::$tpl->fetch('feed.rss.tpl');
		exit();
	}
	
	function __destruct(){}
}	
?>